package ai.people.netmon.framework.domain.archives.dto;

import ai.people.netmon.framework.model.response.PageResponse;
import lombok.Data;

import java.util.Collection;
import java.util.Collections;

/**
 * @author LiGuanNan
 * @date 2022/6/10 17:55
 */
@Data
public class ThirdPartySearchPageResponse <T> {
    /**
     * 数据
     */
    private Collection<T> list;
    /**
     * 总计
     */
    private Long total = 0L;

    /**
     * 页数
     */
    private Long pages = 0L;
    /**
     * 当前
     */
    private Long pageNo = 1L;
    /**
     * 每页条数
     */
    private Long pageSize = 50L;

    public ThirdPartySearchPageResponse(Collection<T> data, long total) {
        this.list = data;
        this.total = total;
    }

    public ThirdPartySearchPageResponse(Collection<T> data, long total, long pages, long pageNo) {
        this.list = data;
        this.total = total;
        this.pages = pages;
        this.pageNo = pageNo;
    }

    /**
     * 构建器
     *
     * @return {@link PageResponse}<{@link T}>
     */
    public static <T> ThirdPartySearchPageResponse<T> builderEmpty() {
        return builder(Collections.emptyList(), 0);
    }

    /**
     * 构建器
     *
     * @param data  数据
     * @param total 总计
     * @return {@link PageResponse}<{@link T}>
     */
    public static <T> ThirdPartySearchPageResponse<T> builder(Collection<T> data, long total) {
        return new ThirdPartySearchPageResponse<>(data, total);
    }

    /**
     * 构建器
     *
     * @param data  数据
     * @param total 总计
     * @return {@link PageResponse}<{@link T}>
     */
    public static <T> ThirdPartySearchPageResponse<T> builder(Collection<T> data, long total, long pages, long pageNo) {
        return new ThirdPartySearchPageResponse<>(data, total, pages, pageNo);
    }

}
